package com.zx.system.block.param;

import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.DateTimeFormatEnum;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Create;
import com.zx.validation.groups.Query;
import com.zx.validation.groups.StatusUpdate;
import com.zx.validation.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 * description: 用户参数类 <br>
 * create: 2024-09-25 16:18
 * </p>
 *
 * @author zhou  xun
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class UserParam implements Serializable, Create, Update, Query, StatusUpdate {
    /**
     * 用户id
     */
    @ParameterValidation(index = 0, desc = "用户id", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~32")
    private String id;

    /**
     * 用户姓名
     */
    @ParameterValidation(index = 0, desc = "用户姓名", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~30")
    private String name;

    /**
     * 部门id
     */
    @ParameterValidation(index = 0, desc = "部门Id", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~32")
    private String deptId;

    /**
     * 邮箱
     */
    @ParameterValidation(index = 0, desc = "邮箱", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~50")
    private String email;

    /**
     * 手机号码
     */
    @ParameterValidation(index = 0, desc = "手机号码", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~11")
    private String phoneNumber;

    /**
     * 性别
     */
    @ParameterValidation(index = 0, desc = "性别", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~1")
    private String sex;

    /**
     * 密码
     */
    @ParameterValidation(index = 0, desc = "密码", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~100")
    private String password;

    /**
     * 头像
     */
    @ParameterValidation(index = 0, desc = "头像", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String avatar;

    /**
     * 用户状态(0停用 1启用)
     */
    @ParameterValidation(index = 0, desc = "用户状态", rules = {ValidateRulesEnum.NOT_NULL})
    private Integer status;

    /**
     * 备注
     */
    @ParameterValidation(index = 0, desc = "备注", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String remark;

    /**
     * 创建时间开始
     * 用于时间范围查询，查询大于等于该时间的记录
     */
    @ParameterValidation(index = 0, desc = "创建时间开始", rules = {ValidateRulesEnum.NULL_DATE}, dateFormat = DateTimeFormatEnum.YEAR)
    private LocalDateTime createTimeStart;

    /**
     * 创建时间结束
     * 用于时间范围查询，查询小于等于该时间的记录
     */
    @ParameterValidation(index = 0, desc = "创建时间结束", rules = {ValidateRulesEnum.NULL_DATE}, dateFormat = DateTimeFormatEnum.YEAR)
    private LocalDateTime createTimeEnd;

    /**
     * 当前页码
     */
    @ParameterValidation(index = 0, desc = "当前页码", rules = {ValidateRulesEnum.NUMBER_MIN}, numberMin = 1)
    private Long pageNum;

    /**
     * 每页条数
     */
    @ParameterValidation(index = 0, desc = "每页条数", rules = {ValidateRulesEnum.NUMBER_MIN, ValidateRulesEnum.NUMBER_MAX}, numberMin = 1, numberMax = 1000)
    private Long pageSize;

    @Override
    public Set<String> getCreateGroupFields() {
        return Set.of("name", "deptId", "email", "phoneNumber", "sex", "password", "avatar", "status", "remark");
    }

    @Override
    public Set<String> getUpdateGroupFields() {
        return Set.of("id", "name", "deptId", "email", "phoneNumber", "sex", "avatar", "status", "remark");
    }

    @Override
    public Set<String> getQueryGroupFields() {
        return Set.of("name", "deptId", "email", "phoneNumber", "sex", "status", "createTimeStart", "createTimeEnd", "pageNum", "pageSize");
    }

    @Override
    public Set<String> getStatusUpdateGroupFields() {
        return Set.of("id", "status");
    }
}